package com.ajhond.bingdataview.controller;

import com.ajhond.bingdataview.bean.Result;
import com.ajhond.bingdataview.mapper.CovidMapper;
import org.apache.commons.lang3.time.FastDateFormat;
import org.apache.ibatis.annotations.Select;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("covid")
public class dataController {
    @Autowired
    private CovidMapper covidMapper;
    /**
     * 年龄段分布
     * @return
     */
    @RequestMapping("getCovidAge")
    public Result getCovidAge(){
        String datetime = FastDateFormat.getInstance("yyyy-MM-dd").format(System.currentTimeMillis());
        List<Map<String,Object>> data = covidMapper.getCovidAge(datetime);
        return Result.success(data);
    }
    /**
     * 职业
     */
    @RequestMapping("getCovidZY")
    public Result getCovidZY(){
        String datetime = FastDateFormat.getInstance("yyyy-MM-dd").format(System.currentTimeMillis());
        List<Map<String,Object>> data = covidMapper.getCovidZY(datetime);
        return Result.success(data);
    }
    /**
     * 职业
     */
    @RequestMapping("getCovidShop")
    public Result getCovidShop(){
        String datetime = FastDateFormat.getInstance("yyyy-MM-dd").format(System.currentTimeMillis());
        List<Map<String,Object>> data = covidMapper.getCovidShop(datetime);
        return Result.success(data);
    }
    /**
     * echarts2
     * 不同商品在各平台的销量
     * @return
     */
    @RequestMapping("getCovidXL")
    public Result getCovidXL(){
        List<Map<String, Object>> data = covidMapper.getCovidXL();
        return Result.success(data);
    }

    /**
     * 地图数据
     * @return
     */
    @RequestMapping("getCovidMapdata")
    public Result getCovidMapdata(){
    String datetime = FastDateFormat.getInstance("yyyy-MM-dd").format(System.currentTimeMillis());
    List<Map<String, Object>>  data = covidMapper.getCovidMapdata(datetime);
    return Result.success(data);
    }
    /**
     * PT
     */
    @RequestMapping("getCovidPTNum")
    public Result getCovidPTNum(){
        String datetime = FastDateFormat.getInstance("yyyy-MM-dd").format(System.currentTimeMillis());
        List<Map<String, Object>>  data = covidMapper.getCovidPTNum(datetime);
        return Result.success(data);
    }

    /**
     * echarts1
     * @return
     */
    @RequestMapping("getCovidGan")
    public Result getCovidGan(){
        List<Map<String,Object>> data = covidMapper.getCovidGan();
        return Result.success(data);

    }
    /**
     * echarts5
     */
    @RequestMapping("getCovidProvince")
    public Result getCovidProvince(){
        List<Map<String,Object>> data = covidMapper.getCovidProvince();
        return Result.success(data);
    }

    /**
     * echarts5
     * @return
     */
    @RequestMapping("getCovidProvinceM")
    public Result getCovidProvinceM(){
        List<Map<String,Object>> data = covidMapper.getCovidProvinceM();
        return Result.success(data);
    }
}
